#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>

#include "s_server.h"

namespace dhd
{
namespace server
{
   using namespace std;
   
   int dhd_server_main(int argc, char *argv[])
   {
       umask(0);
       
       try
       {                             
           Server server( ServerConfig(argc, argv) );
           
           server.main();
       }
       catch( ConfigurationError & e )
       {
           std::cerr << "Configuration error: " << e.what() << std::endl;
           return 1;
       }    
       catch (std::exception& e)
       {
           std::cerr << "Exception: " << e.what() << "\n";
           return 1;
       }
       
       return 0;
   }

}// end namespace dhd::server
}// end namespace dhd



int main(int argc, char *argv[])
{
    return dhd::server::dhd_server_main(argc, argv);
}
